package Leetcode.lc234;

import Leetcode.tools.ListNode;

import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;

public class Sloution {
    /***
     * 回文 1221 若有101这类，不可以用栈
     * @param head
     * @return
     */
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> list = new ArrayList<>();
        ListNode cur=head;
        while (cur!=null){
            list.add(cur.val);
            cur=cur.next;
        }
        int left=0,right=list.size()-1;
        while (left<right){
            if(!list.get(left).equals(list.get(right))) return false;
            left++;
            right--;
        }
        return true;
    }

    public static void main(String[] args) {

    }
}
